<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/12/29
 * Time: 15:45
 */
header('content-type:text/html;charset=utf8');
if ($_FILES['file']['error'] == 0) {
    $fileTmp = $_FILES['file']['tmp_name'];
    $fileType = $_FILES['file']['type'];
    $fileName = $_FILES['file']['name'];
    $postData = array('file' => new \CURLFile(realpath($fileTmp), $fileType, $fileName));
    $postUrl = "http://remote.upload.com/upload.php";
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $postUrl);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
    curl_exec($curl);
    $data = curl_multi_getcontent($curl);//CURL获取返回值方法，下文解释
    curl_close($curl);
} else {
    var_dump($_FILES['file']['error']);
    exit("上传失败");
}

